 <%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<link href="<%=request.getContextPath()%>/stage/css/inside.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/stage/css/page.css" rel="stylesheet" type="text/css" />
<script type="text/javascript"
	src="<%=request.getContextPath()%>/stage/js/jquery-1.4.2.min.js"></script>
<script type="text/JavaScript">
<!--
$(document).ready(function(){
	var showpage=7;//页面显示的数量
	var mid=(showpage-1)/2;//页面显示数量的中间数
	var url ='<%=request.getAttribute("url")%>';
	url=encodeURI(url);
	url=encodeURI(url);
	var herf='<%=request.getContextPath()%>'+"/"+url+"&currpage=";
	var rowcount = <%=request.getAttribute("rowcount")%>;
	var currpage = <%=request.getAttribute("currpage")%>;
	var totalpage = <%=request.getAttribute("totalpage")%>;
	if(rowcount==null)rowcount=0;
	if(currpage==null)currpage=0;
	if(totalpage==null)totalpage=0;
	var content='<span class="page_cur_all">共'+rowcount+'条 第'+currpage+'/'+totalpage+'页</span>';
	//处理上一页
	if(currpage>1){
		content+='<a href="'+herf+(currpage-1)+'">上一页</a>';
	}else{
		content+='<a>上一页</a>';
	}
	
	if(totalpage<=showpage){//如果总页数小于显示页数
		content+=each(1,totalpage,currpage,herf);
	}else if(currpage<=mid){//否则如果当前页小于显示中间数
		content+=each(1,showpage,currpage,herf);
	}else if((totalpage-currpage)<=mid){//否则如果尾页减当前页小于显示中间数
		content+=each((totalpage-showpage+1),totalpage,currpage,herf);
	}else{
		content+=each((currpage-mid),(currpage+mid),currpage,herf);
	}
	if(currpage<totalpage){
		content+='<a href="'+herf+(currpage+1)+'">下一页</a>';
	}else{
		content+='<a>下一页</a>';
	}
	$(".page_cut").html(content);
})
function each(first,end,currpage,herf){
	var str='';
	for(var i=first;i<=end;i++){
		if(i==currpage){
			str+='<span class="cur_page">'+i+'</span>';
		}else{
			str+='<a href="'+herf+i+'">'+i+'</a>';
		}
	}
	return str;
}
//-->
</script>
<div class="page_cut"/>